/*
This file is part of AI Agent Feed.

"AI Agent Feed" is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

"AI Agent Feed" is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with "AI Agent Feed".  If not, see <http://www.gnu.org/licenses/>.
 */
package com.feed.processor;

import org.joda.time.DateTime;

import com.feed.processor.source.XmlSource;
import com.feed.processor.source.impl.StringXmlSource;
import com.feed.protocol.http.HttpProtocolHandler;

public abstract class AbstractHttpFeedProcessor extends AbstractFeedProcessor {

	protected HttpProtocolHandler protocolHandler;
	protected String feedUrl;
	protected String encoding = "UTF-8";
	
	
	protected XmlSource retrieveFeed() {
		String content = getHttpContent();
	    StringXmlSource simpleXmlSource = new StringXmlSource(feedUrl, content);
		return simpleXmlSource;	
	}

	protected String getHttpContent() {
		return protocolHandler.getContentText();
	}

	public void setFeedUrl(String feedUrl) {
		this.feedUrl = feedUrl;
	}
	
	protected String getFeedUrl() {
		return feedUrl;
	}


	public void setEncoding(String encoding) {
		this.encoding  = encoding;
	}

	public DateTime getLastModifiedTimeReportedByFeed() {
		return protocolHandler.getLastModified();
	}
}
